<?php
/**
 * Created by PhpStorm.
 * User: 毛文科
 * Date: 2018/8/23 0023
 * Time: 15:25
 */
namespace app\admin\model;
use think\Db;

class CommentModel
{
    /**获取评论模型
     * @return $this
     */
    static public function getComment(){
        return Db::view('comment',true)
            ->view('user','nickname','user.id=comment.userid','left')
            ->view('company','company_name','company.id=comment.company_id','left')
            ->view('departmen_table','departmen_name','comment.department_id=departmen_table.id','left');
    }

    /**添加评论
     * @param $data
     * @return int|string
     */
    static public function addComment($data){
        return Db::name('comment')->insert($data);
    }

    /**删除评论
     * @param $field
     * @param null $op
     * @param null $condition
     * @return int
     */
    static public function delComment($field, $op = null, $condition = null){
        return Db::name('comment')->where($field,$op,$condition)->delete();
    }

    /**更新评论
     * @param $data
     * @return int|string
     */
    static public function updateComment($data){
        return Db::name('comment')->update($data);
    }
}